import React,{Component} from 'react';
import {Segment,Header,Form,Button} from "semantic-ui-react";
import {ethers} from 'ethers';

class Transaction extends Component{
    constructor(props){
        super(props)
        this.state = {
            txTo:'',
            txValue:0,
            onSendClick:props.onSendClick

        }

    }
    handleChange = (e,{name,value})=>{
        this.setState({[name]:value})
        console.log(name+":"+value)
    }

    onSendClick = ()=>{
        this.state.onSendClick(this.state.txTo,this.state.txValue)
    }

    render() {
        return (
            <Segment stacked textAlign="left">
                <Header as="h1"> 转账 | 提现 </Header>{" "}
                <Form.Input
                    style={{
                        width: "100%"
                    }}
                    action={{
                        color: "teal",
                        labelPosition: "left",
                        icon: "address card",
                        content: "地址"
                    }}
                    actionPosition="left"
                    defaultValue=""
                    type="text"
                    name="txTo"
                    required
                    // value={this.state.txto}
                    placeholder="对方地址"
                    onChange={this.handleChange}
                />{" "}
                <br />
                <Form.Input
                    style={{
                        width: "100%"
                    }}
                    action={{
                        color: "teal",
                        labelPosition: "left",
                        icon: "ethereum",
                        content: "金额"
                    }}
                    actionPosition="left"
                    defaultValue=""
                    type="text"
                    name="txValue"
                    required
                    // value={this.state.txvalue}
                    placeholder="以太"
                    onChange={this.handleChange}
                />
                <br />
                <Button
                    color="twitter"
                    style={{
                        width: "100%"
                    }}
                    size="large"
                    // loading={this.state.loading}
                    onClick={this.onSendClick}
                >
                    确认
                </Button>
            </Segment>
        );
    }


}


export default Transaction;